﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using COM.Data;

namespace COM.Data
{
    public class DatabaseFactoryBase<T> : Disposable, IDatabaseFactoryBase<T> where T:DbContext,new()
    {
        private T dataContext;
        public T Get()
        {
            return dataContext ?? (dataContext = new T());
        }

        protected override void DisposeCore()
        {
            if (dataContext != null)
                dataContext.Dispose();
        }
    }
}
